///************************************************************************
/// <copyrigth>2024-2025 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// It offers conveniently for string/wstring and UTF8 encode in and out
///</describe>
/// <date>2024/1/8</date>
///***********************************************************************
#ifndef STRING_H
#define STRING_H

#include <string>
#include <vector>
#include <iostream>
#include "ModuleLoader/ModuleConfig.h"

namespace SystemTool
{
    class CLASS_ITEM String
    {
    public:
        // Construct the std::string
        String();

        // Construct the std::string
        String(std::string strData);

        // Construct with utf16/utf32 string
        String(std::wstring strData);

        // Construct the std::string
        String(char* pData);

        // Construct the std::string
        String(const char* pData);

        // Construct the utf16/utf32 string
        String(wchar_t* pData);

        // Construct the utf16/utf32 string
        String(const wchar_t* pData);

        // Destruct the String
        ~String();

        // Copy String
        String(const String& other);

        // Assignment of String
        String& operator=(const String& other);

        // Is contain substring
        bool IsContain(String strData);

        // Get string data
        std::string Data();
        
        // Get wstring data
        std::wstring WData();

        // Make upper
        String MakeUpper();

        // Make lower
        String MakeLower();

        // Append data
        String& Append(String strData);

        // Append data
        String& Append(int iData);

        // Append data
        String& Append(unsigned int uData);

        // Append data
        String& Append(long lData);

        // Append data
        String& Append(unsigned long ulData);

        // Append data
        String& Append(long long llData);

        // Append data
        String& Append(unsigned long long ullData);

        // Append data
        String& Append(float fData);
        
        // Append data
        String& Append(double dData);
        
        // + string
        String& operator+(String strData);

        // + string
        String& operator+(int iData);

        // + string
        String& operator+(unsigned int uData);

        // + string
        String& operator+(long lData);

        // + string
        String& operator+(unsigned long ulData);

        // + string
        String& operator+(long long llData);

        // + string
        String& operator+(unsigned long long ullData);

         // + string
        String& operator+(float fData);

        // + string
        String& operator+(double dData);

        // += string
        String& operator+=(String strData);

        // += string
        String& operator+=(int iData);

        // += string
        String& operator+=(unsigned int uData);

        // += string
        String& operator+=(long lData);

        // += string
        String& operator+=(unsigned long ulData);

        // += string
        String& operator+=(long long llData);

        // += string
        String& operator+=(unsigned long long ullData);

         // += string
        String& operator+=(float fData);

         // += string
        String& operator+=(double dData);

        // Format args
        String Args(String strData);

        // Format args
        String Args(int iData);

        // Format args
        String Args(unsigned int uData);

        // Format args
        String Args(long lData);

        // Format args
        String Args(unsigned long ulData);

        // Format args
        String Args(long long llData);

        // Format args
        String Args(unsigned long long ullData);

        // Format args
        String Args(float fData);

        // Format args
        String Args(double dData);

        // Equal
        bool operator==(String& other);

        // Not Equal
        bool operator!=(String& other);

        // Get a data
        wchar_t operator[](int iIndex);

        // Is empty
        bool IsEmpty();

        // Split the string by substring
        bool Split(String strSep,std::vector<String>& vTable);

        // Length of string
        int Length();

        // Get substring
        String SubStr(int iStartPos, int iSubLen);

        // Get substring
        String SubStr(int iStartPos);

        // Get left string from start pos = 0
        String Left(int iLength);

        // Get right string from end pos
        String Right(int iLength);

        // Find a substring
        int Find(String strSubStr,int iStartPos = 0);

        // Find last of sub string
        int FindLastOf(String strSubStr);

        // Replace the sub string
        String& Replace(String strOldStr,String strNewStr);

        // Replace from pos
        String& Replace(int iStartPos, int iReplaceLen,String strNewStr);

        // To int
        int ToInt();

        // To unsigned int
        unsigned int ToUInt();

        // To long
        long ToLong();

        // To unsigned long
        unsigned long ToULong();

        // To long long
        long long ToLongLong();

        // To unsigned long long
        unsigned long long ToULongLong();

        // To float
        float ToFloat();

        // To double
        double ToDouble();

        // From int 
        static String FromInt(int iData);

        // From unsigned int 
        static String FromUInt(unsigned int uData);

        // From long 
        static String FromLong(long lData);

        // From unsigned long 
        static String FromULong(unsigned long ulData);

        // From long long 
        static String FromLLong(long long llData);

        // From unsigned long long 
        static String FromULLong(unsigned long long ullData);

        // From flaot 
        static String FromFloat(float fData);

        // From double
        static String FromDouble(double dData);

    private:
        // std::wstring
        void* m_pWString;
    };
}

#endif // STRING_H
